﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
namespace YAMN_Cinemas.Presentation
{
    public partial class SelectMovie : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           //int movieid;
          
          

          
           // ArrayList list_MovieID = new ArrayList();
           // int length = GridView_Movies.Rows.Count;
           //for (int i = 0; i < length; i++)
           //{
            
           //list_MovieID.Add(movieid);
 
           //}
           // GridView_Movies.Columns[0].Visible = false;

           // //TheatreEntities te = new TheatreEntities();
           // //GridView1.DataSource = te.Movies1;
           // //GridView1.DataBind();
             
           //lbl_test.Text = list_MovieID[1].ToString();
           ////GridView_Movies.Columns[0].Visible = false;
            GridView_New.AutoGenerateSelectButton = true;
            
            TheatreEntities te = new TheatreEntities();
            List<String> screenTime = new List<string>();
            var q = (from m in te.Movies
                     join st in te.Screen_Timings on m.STID equals st.STID
                     select new { m.Movie_Title, m.Language, m.Summary, st.Screen_Time });
            ArrayList list = new ArrayList();
            foreach (var ex in q)
            {
                list.Add(ex);
            }
            GridView_New.DataSource = list;
            GridView_New.DataBind();
        }

        protected void btn_Submit_Click(object sender, EventArgs e)
        {
           

            Service.UserService userser = new Service.UserService();
            long movieid;
           int id = GridView_New.SelectedIndex; //user selected Movie
            TheatreEntities te = new TheatreEntities();
            List<Int64> lis = new List<Int64>();
            lis = (from m in te.Movies
                   select m.MovieID).ToList();
            movieid = lis[id];
            string url="http://localhost:6500/Presentation/U_MovieInfo.aspx?movieID="+movieid.ToString();
            Response.Redirect(url);
            


        }

        protected void GridView_Movies_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}